package cc.armin.service;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cc.armin.entity.User;

public interface UserService {
	@Insert(" insert into user (uid,username,password) values (#{id},#{username},#{password})")
	void add(@Param("id") String id, @Param("username") String username, @Param("password") String password);

	@Delete(" delete from user where uid=#{id}")
	void delete(String id);

	@Update(" update user set username=#{username},password=#{password} where uid=#{id}")
	int update(@Param("username") String username, @Param("password") String password, @Param("id") String id);

	@Select(" select * from user where uid=#{id}")
	User getUser(String id);

	@Select(" select * from user order by uid asc ")
	List<User> getUsers();

	@Select(" select * from user order by uid asc limit #{pageSize} offset #{offset} ")
	List<User> getUsersByPage(@Param("offset") int offset, @Param("pageSize") int pageSize);// offset=pageSize*(page-1)}?
}
